home *** CD-ROM | disk | FTP | other *** search
- Path: info.uah.edu!oreo!gbacon
- From: gbacon@oreo (Greg Bacon)
- Newsgroups: comp.lang.c
- Subject: Re: question on pass-by-reference
- Date: 18 Jan 1996 19:53:26 GMT
- Organization: The University of Alabama in Huntsville
- Message-ID: <4dm8fm$bsi@info.uah.edu>
- References: <4dha4j$4qg@shrike.depaul.edu>
- Reply-To: gbacon@CS.UAH.Edu
- NNTP-Posting-Host: oreo.aspire.cs.uah.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Kazuki Murakami (kmurakam@shrike.depaul.edu) wrote:
-
- : I have a question on pass-by-reference.
- : Here is a problem, I want to set array of unsigned short number to be
- : all 0 using a function. here is what set looks like:
-
- : typedef unsigned short USHORT;
- : typedef USHORT SET[32];
-
- : void setInit (SET *s)
- : {
- : int i;
-
- : for (i=0; i<32; i++)
- : {
- : *s[i] = 0;
- : }
- : }
-
- : here is the calling function.
- : setInit(&set1); setInit(&set2);
-
- : I think there is somthing wrong in "setInit" function but I cannot
- : seem to figure out what that is. If somebody can figure out what
- : that is or some other way of initializing "SET s" please give me a
- : e-mail.
-
- : Thank you
- :
- : Kazuki Murakami
-
- OK.. you want your setInit() function to look like this:
-
- void setInit(USHORT *set)
- {
- int i;
-
- for(i = 0; i < 32; i++)
- *(set + i) = 0;
- }
-
- and call it like this..
-
- {
- SET set1, set2;
-
- setInit(set1);
- setInit(set2);
-
- Neat how that whole equivalence of pointers and arrays works in C, ain't
- it? :)
-
- Greg
- --
- Greg Bacon <gbacon@cs.uah.edu>
- University of Alabama in Huntsville
- CS Department Systems Support Team
-